import { _decorator, Component, EventTouch, Input, input, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('CameraController')
export class CameraController extends Component {
    start() {
        input.on(Input.EventType.TOUCH_START, this.onTouchStart, this);
        input.on(Input.EventType.TOUCH_MOVE, this.onTouchMove, this);
        input.on(Input.EventType.TOUCH_END, this.onTouchEnd, this);
    }

    onTouchStart(event: EventTouch) {
        console.log('touch start');
    }

    onTouchMove(event: EventTouch) {
       

        console.log('touch move' + event.getDelta().toString());
        
        const scale = 0.05;
        const pos = this.node.position;
        this.node.setPosition(pos.x + event.getDelta().x * scale, pos.y + event.getDelta().y * scale, pos.z);

    }


    onTouchEnd(event: EventTouch) {
        console.log('touch end');
    }

    update(deltaTime: number) {
    }
}


